<template>
	<view class="content">
		<view class="tabs">
			<view class="tab" @tap="changeSwiper(index)" :class="{active:tab_index == index}" v-for="(item,index) in tabs" :key="index">{{item}}</view>
		</view>
		<!-- <swiper :current="tab_index" @change="swiperChange"> -->
			<!-- 全部农户 -->
			<view v-if="tab_index == 0">
				<view class="swiper-item">
					<view class="item">
						<view class="colmun" @tap="goDetail(item)" v-for="(item,index) in list" :key="index">
							<text>{{item.nickname}}</text>
							<text class="phone">{{item.mobile}}</text>
							<image src="../../../static/right.png" mode=""></image>
						</view>
					</view>
				</view>
			</view>
			<!-- 项目待分配 -->
			<view v-if="tab_index == 1">
				<view class="swiper-item">
					<view class="item">
						<view class="colmun" @tap="goFen(item.user_id,item.id)" v-for="(item,index) in list" :key="index">
							<text>{{item.nickname}}</text>
							<text class="phone">{{item.mobile}}</text>
							<image src="../../../static/right.png" mode=""></image>
						</view>
					</view>
				</view>
			</view>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabs:['全部农户','项目待分配'],
				tab_index:0,
				page: 1,
				list: [],
				taaa: [],
				last_page: 1,
				
			}
		},
		onReachBottom() {
			// if(this.last_page - this.page >= 0){
				this.page++;
				this.loadData()
			// }
		},
		 
		onLoad() {
			this.loadData()
		},
		methods: {
			changeSwiper(index){
				this.page = 1;
				this.tab_index = index;
				this.loadData();
			},
			loadData(){
				  console.log(this.page+"aaa")
				this.$http.post('/api/userinfo/userindex',{
					type: parseInt(this.tab_index + 1),
					limit: '15',
					page:this.page,
				}).then(res => {
					 console.log(res.data.data)
					  console.log(this.page+"bbbb")
					// this.last_page = res.data.data.last_page;
					 if(this.page == 1){
						this.list = res.data.data
						this.page = 1
					}
					else{
						this.taaa=res.data.data
						this.list = Object.assign(this.list,this.taaa)
						console.log(333)
						console.log(this.list)
						console.log(333)
					}
				})
			},
			goDetail(item){
				uni.navigateTo({
					url:'/pages/componentB/nongdata/nongdata?item=' + encodeURIComponent(JSON.stringify(item))
				})
			},
			goFen(id){
				uni.navigateTo({
					url:'/pages/componentB/nongfen/nongfen?user_id=' + id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.content{
	min-height: 100vh;
	background-color: #F8F8F8;
	padding: 5rpx 30rpx 80rpx;
	box-sizing: border-box;
}
.tabs{
	display: flex;
	justify-content: flex-start;
	align-items: center;
	padding: 30rpx 0rpx;
	box-sizing: border-box;
	.tab{
		font-size:15px;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(51,51,51,1);
		margin-right: 80rpx;
		&.active{
			font-size:20px;
			font-family:PingFang SC;
			font-weight:bold;
			color:rgba(63,195,119,1);
		}
	}
}
// swiper{
// 	height: calc(100vh - 116rpx);
// 	overflow: scroll;
// }
// .swiper-item{
// 	height: calc(100vh - 116rpx);
// 	overflow: scroll;
// }
.item{
	padding: 0 30rpx;
	box-sizing: border-box;
	width: 690rpx;
	background:rgba(255,255,255,1);
	border-radius:20px;
	margin-bottom: 30rpx;
}
.colmun{
	padding: 30rpx;
	box-sizing: border-box;
	display: flex;
	justify-content: flex-start;
	align-items: center;
	border-bottom: 1px solid rgba(0,0,0,.05);
	&:last-child{
		border: none;
	}
	text{
		font-size:17px;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(51,51,51,1);
	}
	.phone{
		font-size:13px;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(153,153,153,1);
		flex: 1;
		margin: 0 30rpx;
	}
	image{
		width:12rpx;
		height:23rpx;
	}
}
</style>
